home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 1.0 / CIncludes / iomanip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-18  |  6.9 KB  |  129 lines  |  [TEXT/MPS ]

  1. /*
  2.  *------------------------------------------------------------------------
  3.  * Copyright:
  4.  *      © 1993 by Apple Computer Inc.  all rights reserved.
  5.  *
  6.  * Project:
  7.  *      PowerPC C++ Streams Library
  8.  *
  9.  * Filename:
  10.  *      iomanip.h
  11.  *
  12.  * Created:
  13.  *      (unknown)
  14.  *
  15.  * Modified:
  16.  *      Date     Engineer       Comment
  17.  *      -------- -------------- ------------------------------------------
  18.  *      12/17/93 Rudy Wang      Made this file universal.
  19.  *------------------------------------------------------------------------
  20.  */
  21. #ifndef __IOMANIPH__
  22. #define __IOMANIPH__       1
  23.  
  24. #include <generic.h>
  25.  
  26. #define SMANIP(T)name2(smanip_,T)
  27. #define SAPP(T)name2(sapply_,T)
  28. #define IMANIP(T)name2(imanip_,T)
  29. #define OMANIP(T)name2(omanip_,T)
  30. #define IOMANIP(T)name2(iomanip_,T)
  31. #define IAPP(T)name2(iapply_,T)
  32. #define OAPP(T)name2(oapply_,T)
  33. #define IOAPP(T)name2(ioapply_,T)
  34.  
  35. /*
  36.  *------------------------------------------------------------------------
  37.  * NOTE: (For users of the following macro)
  38.  * Whenever the following macro is used, proper structure alignment pragma
  39.  * should used to ensure the uniformity of the structure's alignment.
  40.  *------------------------------------------------------------------------
  41.  */
  42. #define IOMANIPdeclare(T)                                               \
  43. class SMANIP(T) {                                                       \
  44.         ios& (*fct)(ios&,T);                                            \
  45.         T arg;                                                          \
  46. public:                                                                 \
  47.         SMANIP(T)(ios& (*f)(ios&, T), T a) :                            \
  48.                         fct(f), arg(a) { }                              \
  49.         friend istream& operator>>(istream& i, SMANIP(T)& m) {          \
  50.                         ios* s = &i;                                    \
  51.                         (*m.fct)(*s,m.arg);  return i;  }               \
  52.         friend ostream& operator<<(ostream& o, SMANIP(T)& m) {          \
  53.                         ios* s = &o;                                    \
  54.                         (*m.fct)(*s,m.arg);  return o;  }               \
  55.         };                                                              \
  56. class SAPP(T) {                                                         \
  57.         ios& (*fct)(ios&, T);                                           \
  58. public:                                                                 \
  59.         SAPP(T)(ios& (*f)(ios&,T)) : fct(f) { }                         \
  60.         SMANIP(T) operator()(T a) {                                     \
  61.                         return SMANIP(T)(fct,a);  }                     \
  62.         };                                                              \
  63. class IMANIP(T) {                                                       \
  64.         istream& (*fct)(istream&,T);                                    \
  65.         T arg;                                                          \
  66. public:                                                                 \
  67.         IMANIP(T)(istream& (*f)(istream&, T), T a ) :                   \
  68.                 fct(f), arg(a) { }                                      \
  69.         friend istream& operator>>(istream& s, IMANIP(T)& m) {          \
  70.                 return(*m.fct)(s,m.arg);                                \
  71.                 }                                                       \
  72.         };                                                              \
  73. class IAPP(T) {                                                         \
  74.         istream& (*fct)(istream&, T);                                   \
  75. public:                                                                 \
  76.         IAPP(T)(istream& (*f)(istream&,T)) : fct(f) { }                 \
  77.         IMANIP(T) operator()(T a) {                                     \
  78.                         return IMANIP(T)(fct,a);  }                     \
  79.         };                                                              \
  80. class OMANIP(T) {                                                       \
  81.         ostream& (*fct)(ostream&,T);                                    \
  82.         T arg;                                                          \
  83. public:                                                                 \
  84.         OMANIP(T)(ostream& (*f)(ostream&, T), T a ) :                   \
  85.                 fct(f), arg(a) { }                                      \
  86.         friend ostream& operator<<(ostream& s, OMANIP(T)& m) {          \
  87.                 return(*m.fct)(s,m.arg);                                \
  88.                 }                                                       \
  89.         };                                                              \
  90. class OAPP(T) {                                                         \
  91.         ostream& (*fct)(ostream&, T);                                   \
  92. public:                                                                 \
  93.         OAPP(T)(ostream& (*f)(ostream&,T)) : fct(f) { }                 \
  94.         OMANIP(T) operator()(T a) {                                     \
  95.                         return OMANIP(T)(fct,a);  }                     \
  96.         };                                                              \
  97. class IOMANIP(T) {                                                      \
  98.         iostream& (*fct)(iostream&,T);                                  \
  99.         T arg;                                                          \
  100. public:                                                                 \
  101.         IOMANIP(T)(iostream& (*f)(iostream&, T), T a ) :                \
  102.                 fct(f), arg(a) { }                                      \
  103.         friend istream& operator>>(iostream& s, IOMANIP(T)& m) {        \
  104.                 return(*m.fct)(s,m.arg);                                \
  105.                 }                                                       \
  106.         friend ostream& operator<<(iostream& s, IOMANIP(T)& m) {        \
  107.                 return(*m.fct)(s,m.arg);                                \
  108.                 }                                                       \
  109.         };                                                              \
  110. class IOAPP(T) {                                                        \
  111.         iostream& (*fct)(iostream&, T);                                 \
  112. public:                                                                 \
  113.         IOAPP(T)(iostream& (*f)(iostream&,T)) : fct(f) { }              \
  114.         IOMANIP(T) operator()(T a) {                                    \
  115.                         return IOMANIP(T)(fct,a);  }                    \
  116.         };                                                              \
  117.  
  118. IOMANIPdeclare(int);
  119. IOMANIPdeclare(long);
  120.  
  121. SMANIP(int)     setbase(int b);         /* 10, 8, 16 or 0 */
  122. SMANIP(long)    resetiosflags(long b);
  123. SMANIP(long)    setiosflags(long b);
  124. SMANIP(int)     setfill(int f);
  125. SMANIP(int)     setprecision(int p);
  126. SMANIP(int)     setw(int w);
  127.  
  128. #endif
  129.